package cn.tedu.sp06;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@EnableDiscoveryClient
public class Sp06RibbonApplication {
    /**
     * @LoadBalanced 负载均衡注解，会对 RestTemplate 实例进行封装，创建动态代理对象，
     * 并切入（AOP）负载均衡代码，把请求分发到集群中的服务器
     * @return
     */
    @LoadBalanced //负载均衡注解
    //创建 RestTemplate 实例，并存入 spring 容器
    @Bean
    public RestTemplate getRestTemplate() {
        return new RestTemplate();
    }
    public static void main(String[] args) {
        SpringApplication.run(Sp06RibbonApplication.class, args);
    }


}
